package com.example.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.User;
import com.example.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author: chengxuefei
 * @Date: 2021/7/2 0026
 * @Time: 15:23
 */
@Service
@Transactional()
public class UserService extends ServiceImpl<UserMapper, User> {
    @Resource
    private UserMapper userMapper;
    public User Sel(int id){
        User user = userMapper.selectById(id);
        return user;
    }
    @Transactional()
    public void add(User user) throws Exception {
        userMapper.insertUser(user);

    }
    @Transactional()
    public void update(User user){
        userMapper.updateById(user);
    }
    public void updateSql(){
        userMapper.updateSql();
    }
    @Transactional()
    public void delete(int id) {
        userMapper.deleteById(id);
    }

    public String getVersion() {

        return userMapper.getVersion();
    }
}
